package com.mon4cc.simulation.dataranger;

import org.springframework.util.Assert;

import java.util.Random;

/**
 * @author Ping
 * @date 2022/12/20 16:33
 **/
public class IntegerRanger implements DataRanger {
    private int left ;
    private int right ;
    private Random rand = new Random(System.currentTimeMillis()) ;

    public IntegerRanger(int left, int right) {
        this.left = left;
        this.right = right;
        Assert.state(right > left, "Integer ranger should be with correct right and left.");
    }

    @Override
    public Object nextValue() {
        return left + rand.nextInt(right-left);
    }
}
